﻿<div ms-controller="tempview">
    <div class="sui-form form-inline" style="padding-top:5px;">
        城市：
        <select class="input-medium input-xfat" ms-duplex="Client">
            <option value="0">请选择城市</option>
            <option ms-repeat-el="ClientList" ms-attr-value="el.ID">{{el.CodeName}}</option>
        </select>

        <input type="text" ms-duplex="searchkey" placeholder="关键字搜索" class="input-large input-xfat" />
        <a class="sui-btn btn-large btn-primary" style="margin-left:10px;" ms-click="GetLIST()">查询</a>
        <a style="margin-left:10px;" class="sui-btn btn-large btn-success" ms-click="ADD('')">添加</a>
    </div>


    <table class="sui-table table-primary table-zebra">
        <thead>
            <tr>
                <th style="width:60px">城市</th>
                <th>社区名称</th>
                <th>社区图片</th>
                <th>位置</th>
                <th>加入人员</th>
                <th>状态</th>
                <th style="width:80px">加入时间</th>
                <th style="width:210px">操作</th>
            </tr>
        </thead>
        <tbody>
            <tr ms-repeat-el="ListData">
                <td>{{el.CodeName}}</td>
                <td>{{el.Title}}</td>
                <td><img ms-src="ComFunJS.FilePath(el.ImgUrl,'/50/50')" /></td>
                <td>{{el.County}}{{el.Address}}</td>
                <td><a href="javascript:void(0)" ms-click="SHOW(el)">加入人员</a></td>
                <td>
                    <span class="sui-text-success" ms-if="el.Status==0">待审核</span>
                    <span class="sui-text-success" ms-if="el.Status==1">正常</span>
                    <span class="sui-text-danger"  ms-if="el.Status==9">禁用</span>
                    <span class='sui-text-success' ms-visible="el.IsShelf==1">上架</span>
                    <span class='sui-text-danger' ms-visible="el.IsShelf!=1">下架</span>
                    <br />
                    <span class="sui-text-success" ms-if="el.IsSend==1">开通配送</span>
                    <span class="sui-text-danger" ms-if="el.IsSend!=1">未开通配送</span>
                </td>
                <td>{{el.CRTime|date('yyyy-MM-dd')}}</td>
                <td>
                    <a href="javascript:void(0);" class="sui-btn btn-bordered btn-success" ms-click="ADD(el)">编辑</a>
                    <!--<a href="javascript:void(0);" class="sui-btn btn-bordered btn-warning" ms-click="Check(el)" ms-if="el.Status!=0">{{el.Status==1?'禁用':'启用'}}</a>-->
                    <a href="javascript:void(0);" class="sui-btn btn-bordered btn-warning" ms-click="SetShelf(el)">{{el.IsShelf==1?'下架':'上架'}}</a>
                    <a href="javascript:void(0);" class="sui-btn btn-bordered btn-info" ms-click="Send(el)">{{el.IsSend==1?'关闭配送':'开通配送'}}</a>
                </td>
            </tr>
        </tbody>
    </table>

</div>
<script type="text/javascript">
    var tempmodel = avalon.define({
        $id: "tempview",
        SHOW: function (el) {
            top.ComFunJS.winShowForm("/admin/base/list2.html?funcode=shequuser&id=" + el.ID, "查看");
        },
        Client: "0",
        ClientList:[],
        usertype: "",
        Init: function () {
            $.getJSON("/adapi/base/client/list", function (r) {
                if (r.error == "") {
                    tempmodel.ClientList = r.result;
                }

            })
            tempmodel.GetLIST();
        },
        Type1: "",
      
        GetLIST: function () {
            model.page.pageindex = 1;
            model.ListData.clear();
            $.getJSON("/adapi/shequ/list/" + tempmodel.Client, { pageindex: model.page.pageindex, pagesize: model.page.pagesize, key: model.searchkey }, function (r) {
                if (r.error == "") {
                    model.ListData = r.result;
                    model.total = r.total;

                    $("#pageDiv").pagination({  //分页容器
                        styleClass: ['sui-pagination'],  //分页样式
                        //showCtrl: false,
                        displayPage: 6,
                        itemsCount: r.total,
                        pageSize: model.page.pagesize,
                        onSelect: function (num) {
                            model.page.pageindex = num;
                            $.getJSON("/adapi/shequ/list/" + tempmodel.Client, { pageindex: model.page.pageindex, pagesize: model.page.pagesize, key: model.searchkey }, function (r) {
                                model.ListData.clear();
                                model.ListData = r.result;
                            })
                        }
                    })

                    $('#pageDiv').pagination('updateItemsCount', r.total, 1);
                }
            })
        },
        Check: function (el) {
            var st = 0;
            if (el.Status == 1) {
                st = 0
            } else {
                st = 1;
            }
            $.getJSON("/adapi/shequ/check/" + el.ID + "/" + st, function (r) {
                if (r.error == "") {
                    el.Status = st;
                }
            });
        },
        Send: function (el) {
            $.getJSON("/adapi/shequ/send/" + el.ID, function (r) {
                if (r.error == "") {
                    el.IsSend = el.IsSend == 1 ? 0 : 1;
                }
            });
        }
    });

</script>
